package com.flexrrb.controls
{
	import mx.controls.DateChooser;
	import mx.core.mx_internal;
	import mx.events.CalendarLayoutChangeEvent;
	import mx.events.DateChooserEvent;
	import mx.styles.StyleProxy;
	use namespace mx_internal;

	public class SuperDateChooser extends DateChooser
	{
		public function SuperDateChooser()
		{
			super();
		}
		//private var dateGrid1:RRBCalendarLayout;
		override protected function createChildren():void
		{
			super.createChildren();
			//if (!dateGrid)
			//{
				dateGrid=new RRBCalendarLayout();
				dateGrid.styleName=new StyleProxy(this, calendarLayoutStyleFilters);
				addChildAt(dateGrid, 2);
				dateGrid.addEventListener(CalendarLayoutChangeEvent.CHANGE, dateGrid_changeHandler);
				dateGrid.addEventListener(DateChooserEvent.SCROLL, dateGrid_scrollHandler);
			//}
		}

		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
		{
			super.updateDisplayList(unscaledWidth, unscaledHeight);
		}

		private function dateGrid_changeHandler(event:CalendarLayoutChangeEvent):void
		{
			//_selectedDate=CalendarLayout(event.target).selectedDate;

			var e:CalendarLayoutChangeEvent=new CalendarLayoutChangeEvent(CalendarLayoutChangeEvent.CHANGE);
			e.newDate=event.newDate;
			e.triggerEvent=event.triggerEvent;
			dispatchEvent(e);
		}

		private function dateGrid_scrollHandler(event:DateChooserEvent):void
		{
			dispatchEvent(event);
		}
	}
}